﻿<UserControl x:Class="MoonyDesk.PluginSettingsCtrl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MoonyDesk"
             xmlns:conv="clr-namespace:MoonyDesk.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <conv:DoubleToIntConverter x:Key="doubleToIntConverter"/>
        <Style TargetType="{x:Type local:PluginSettingsTab}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:PluginSettingsTab}">
                        <Grid Background="Transparent" SnapsToDevicePixels="True" MinHeight="20">
                            <Border
                                x:Name="Border"
                                BorderThickness="1,0,1,0"
                                Margin="0,2,0,2">
                                <Border
                                    BorderThickness="1,0,1,0">
                                    <Border.Background>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                            <GradientStop Offset="0" Color="#00000000"></GradientStop>
                                            <GradientStop Offset="0.45" Color="#22000000"></GradientStop>
                                            <GradientStop Offset="0.45" Color="#28000000"></GradientStop>
                                            <GradientStop Offset="1" Color="#00000000"></GradientStop>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <Border.BorderBrush>
                                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                            <GradientStop Offset="0" Color="#00000000"></GradientStop>
                                            <GradientStop Offset="0.5" Color="#44000000"></GradientStop>
                                            <GradientStop Offset="1" Color="#00000000"></GradientStop>
                                        </LinearGradientBrush>
                                    </Border.BorderBrush>
                                </Border>
                                <Border.BorderBrush>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientStop Offset="0" Color="#11000000"></GradientStop>
                                        <GradientStop Offset="0.5" Color="#66000000"></GradientStop>
                                        <GradientStop Offset="1" Color="#11000000"></GradientStop>
                                    </LinearGradientBrush>
                                </Border.BorderBrush>
                            </Border>
                            <ContentPresenter
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                ContentSource="Header"
                                Margin="4" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Border" Property="Visibility" Value="Visible" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="False">
                                <Setter TargetName="Border" Property="Visibility" Value="Hidden" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type TabControl}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Border
                                Grid.Row="0"
                                BorderThickness="0,0,0,1"
                                BorderBrush="#63727C"
                                Padding="4,0,4,0">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0,1">
                                        <GradientStop Offset="0" Color="#EDF1F4" />
                                        <GradientStop Offset="1" Color="#DCE8EF" />
                                    </LinearGradientBrush>
                                </Border.Background>
                                <StackPanel
                                    Orientation="Horizontal"
                                    Panel.ZIndex="1" 
                                    IsItemsHost="True"
                                    HorizontalAlignment="Left" />
                            </Border>
                            <Border 
                                Grid.Row="1"
                                Background="White">
                                <ContentPresenter ContentSource="SelectedContent" />
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="PosButtonStyle" TargetType="RepeatButton" BasedOn="{StaticResource ResourceKey={x:Type RepeatButton}}">
            <Setter Property="FontSize" Value="30" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Width" Value="40" />
            <Setter Property="Height" Value="40" />
            <Setter Property="Interval" Value="5" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <TabControl x:Name="TabControl">
            <local:PluginSettingsTab x:Name="PositionTab" Text="Position" ImageSource="../images/position.png">
                <Grid Margin="7">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <RepeatButton
                            Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0"
                            HorizontalAlignment="Center"
                            Style="{StaticResource ResourceKey=PosButtonStyle}"
                            Click="MoveUp_Click">
                            <Viewbox Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <Polygon Points="0.5,0 1,1 0,1 0.5,0" Fill="#99000000" />
                            </Viewbox>
                        </RepeatButton>
                        <RepeatButton 
                            Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2"
                            HorizontalAlignment="Center"
                            Style="{StaticResource ResourceKey=PosButtonStyle}"
                            Click="MoveDown_Click">
                            <Viewbox Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <Polygon Points="0,0 1,0 0.5,1 0,0" Fill="#99000000" />
                            </Viewbox>
                        </RepeatButton>
                        <RepeatButton 
                            Grid.Column="0" Grid.Row="1"
                            Style="{StaticResource ResourceKey=PosButtonStyle}"
                            Click="MoveLeft_Click">
                            <Viewbox Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <Polygon Points="0,0.5 1,0 1,1 0,0.5" Fill="#99000000" />
                            </Viewbox>
                        </RepeatButton>
                        <RepeatButton
                            Grid.Column="2" Grid.Row="1"
                            Style="{StaticResource ResourceKey=PosButtonStyle}"
                            Click="MoveRight_Click">
                            <Viewbox Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center">
                                <Polygon Points="0,0 1,0.5 0,1 0,0" Fill="#99000000" />
                            </Viewbox>
                        </RepeatButton>
                        <Border
                            Grid.Column="1" Grid.Row="1"
                            Width="80" Height="60">
                            <StackPanel 
                                Orientation="Horizontal"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center">
                                <TextBlock FontWeight="Bold" Text="X: "></TextBlock>
                                <TextBlock Text="{Binding Path=Left}"></TextBlock>
                                <TextBlock FontWeight="Bold" Text=" Y: "></TextBlock>
                                <TextBlock Text="{Binding Path=Top}"></TextBlock>
                            </StackPanel>
                        </Border>
                    </Grid>
                    <StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Left">
                        <CheckBox IsChecked="{Binding Path=Movable}" Margin="0,0,0,3">Movable by mouse</CheckBox>
                        <CheckBox IsChecked="{Binding Path=Topmost2}">Topmost</CheckBox>
                    </StackPanel>
                </Grid>
            </local:PluginSettingsTab>
            <local:PluginSettingsTab x:Name="SizeTab" Text="Size" ImageSource="../images/size.png">
                <Border VerticalAlignment="Center" Padding="7">
                    <Slider
                        LargeChange="10.0"
                        SmallChange="1.0"
                        Minimum="20"
                        Maximum="800"
                        Value="{Binding Path=Width, Mode=TwoWay}">
                    </Slider>
                </Border>
            </local:PluginSettingsTab>
            <local:PluginSettingsTab x:Name="RotateTab" Text="Rotate" ImageSource="../images/rotate.png">
                <Border VerticalAlignment="Center" Padding="7">
                    <StackPanel>
                        <Slider
                    LargeChange="5.0"
                    SmallChange="1.0"
                    Minimum="-270"
                    Maximum="270"
                    Value="{Binding Path=Angle, Mode=TwoWay, Converter={StaticResource doubleToIntConverter}}">
                        </Slider>
                        <Grid>
                            <TextBlock>-270°</TextBlock>
                            <TextBlock HorizontalAlignment="Center">0°</TextBlock>
                            <TextBlock HorizontalAlignment="Right">270°</TextBlock>
                        </Grid>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <TextBlock Text="Current: "></TextBlock>
                            <TextBlock Text="{Binding Path=Angle}"></TextBlock>
                            <TextBlock Text="°"></TextBlock>
                        </StackPanel>
                    </StackPanel>
                </Border>
            </local:PluginSettingsTab>
        </TabControl>
    </Grid>
</UserControl>
